Data-driven optimization for microgrid control under distributed energy resource variability

The integration of renewable energy resources into the smart grids improves the system resilience, provide sustainable demand-generation balance, and produces clean electricity with minimal leakage currents. However, the renewable sources are intermittent in nature. Therefore, it is necessary to develop scheduling strategy to optimise hybrid PV-wind-controllable distributed generator based Microgrids in grid-connected and stand-alone modes of operation. In this manuscript, a priority-based cost optimization function is developed to show the relative significance of one cost component over another for the optimal operation of the Microgrid. The uncertainties associated with various intermittent parameters in Microgrid have also been introduced in the proposed scheduling methodology. The objective function includes the operating cost of CDGs, the emission cost associated with CDGs, the battery cost, the cost of grid energy exchange, and the cost associated with load shedding. A penalty function is also incorporated in the cost function for violations of any constraints. Multiple scenarios are generated using Monte Carlo simulation to model uncertain parameters of Microgrid (MG). These scenarios consist of the worst as well as the best possible cases, reflecting the microgrid’s real-time operation. Furthermore, these scenarios are reduced by using a k-means clustering algorithm. The reduced procedures for uncertain parameters will be used to obtain the minimum cost of MG with the help of an optimisation algorithm. In this work, a meta-heuristic approach, grey wolf optimisation (GWO), is used to minimize the developed cost optimisation function of MG. The standard LV Microgrid CIGRE test network is used to validate the proposed methodology. Results are obtained for different cases by considering different priorities to the sub-objectives using GWO algorithm. The obtained results are compared with the results of Jaya and PSO (particle swarm optimization) algorithms to validate the efficacy of the GWO method for the proposed optimization problem.

Deterministic algorithms like linear programming, mixed-integer linear programming, and dynamic programming have been used in articles [9][10][11][12][13][14][15] for unit commitment and economic load dispatch (ELD) of microgrids with or without the energy storage system.Various objectives, i.e. cost minimization, reliability maximization, emission reduction, power loss minimization, voltage security, and utilization of bio-waste in microgrids, are developed with multiple constraints in these papers.However, deterministic methods have some drawbacks: (a) they take more time with the complexity of the problem; (b) they become intractable with the increase in the number of parameters; (c) they have a high dependency on the initial solutions; (d) these methods are gradientdependent, etc.Using meta-heuristic algorithms has resolved the issues related to deterministic methods.Some of the meta-heuristic algorithms, like a genetic algorithm (GA), modified genetic algorithm, particle swarm optimization (PSO), modified particle-swarm optimization (MPSO), grey-wolf optimization (GWO), artificial fish algorithms, african vultures optimization algorithms (AVOA) etc. were used in the literature [16][17][18][19][20][21][22][23][24][25][26][27][28][29][30][31][32] to solve the optimization problems of MG.A GA has been used in the papers 16 and 17 for the energy trading strategy of the MG considering uncertain quantities.
In Ref. 16 , the energy trading strategy was developed for optimal scheduling of conventional generators, energy storage systems, and grid power exchanges.In Ref. 17 , the objective is cost minimization, including the installation cost of battery storage, solar modules, and the operational cost of diesel generators.The goal is subjected to equality constraints like active and reactive power balance and inequality constraints to ensure stability.A modified genetic algorithm has been used in article 18 to share the power generation among the various DERs optimally.The results show that the modified GA gives better results than the GA.
PSO-based optimization algorithms have been developed in article 19,21,22,33 for the ELD problems with multiple thermal units, energy storage devices, etc.Some of these works include the impact of large-scale EV integration along with the numerous constraints and load uncertainty.These studies show that the results obtained by the PSO algorithm are much better than those obtained by the GA.However, in article [24][25][26]34 researchers have analyzed the performance of variants of PSO named "improved, coordinated aggregation-based particle swarm optimization (ICA-PSO)" algorithm and "PSO with BA parameter inspired acceleration coefficients (MHPSO-BAAC)" to solve the ELD problem with valve point loading for all combinations of RES-based power plants. Thse algorithms proved that the PSO variants performed better than basic PSO.
In papers 27,35 , another meta-heuristic-based Grey Wolf Optimization algorithm has been developed to solve the economic operation of the microgrid system, the sizing optimization of BESS, etc.The results obtained by GWO have been compared with the results of other meta-heuristic algorithms like GA, PSO, ABC, etc. to show the effectiveness of GWO.A fuzzy PID control based modified slime mould algorithm (MSMA) is developed for optimal battery management system in article 30 .In this article, the tuning of fuzzy PID controller is performed to accommodate the uncertainties of the automatic voltage variation and power management.An African vultures optimization algorithm (AVOA) has been developed in article 31 for the optimization of a novel two-degree of freedom PID (2DOFPID) controller to emulate the virtual inertia and damping into the Microgrid.The performance of the proposed controller has been compared with the other conventional controller to show its effectiveness.The developed methodlogy 31 has also been validated on OPAL-RT real time environmental simulator.A slime mold meta-heuristic optimization algorithm for the operation management of Microgrids considering Demand Response Program (DRP) is presented in article 32 .The obtained results show that the developed slime mold optimization algorithm performs better than PSO and Genetic Algorithms.
From the above-discussed literature, the key limitations of the work have been identified and presented as follows: (i) Few studies consider the deterministic approach, and others use the stochastic process; however, computational tractability is an issue.(ii) The scheduling under uncertainty is addressed by a reduced number . of scenarios of load, PV, wind, etc., which makes the system unrealistic.(iii).Only a few pieces of literature have discussed the priority factor-based cost components and the static penalty associated with constraints and limit violations; it needs further investigation.
The main contribution of this work is listed below: • To tackle the volatile and intermittent nature of PV, wind, and load, maximum scenarios are considered to represent the real system.• Economic scheduling in both grid-connected and islanded modes uses the concept of load and power cur- tailment with the help of the GWO algorithm, considering the entire day of system data.• A combination of the stochastic nature of resources, unpredictable loads, and the heuristic approach to solv- ing the problem.• An optimal scheduling methodology for MG considering uncertain parameters is proposed along with the existence of an energy storage system.
The remaining paper is organised as follows: In Sect."Optimal operation of microgrid", the optimal operation of MG is discussed.Section "Results and discussion" describes the results and discussion of the proposed methodology, whereas Sect."Conclusion" gives the conclusion part of the work.

Optimal operation of microgrid
The microgrid can be operated in two modes, grid-connected or stand-alone.The fundamental steps of the proposed optimal scheduling strategy of the microgrid in both modes are given: 1. Component modeling

Component modelling
The basic structure of a grid-connected microgrid is shown in Fig. 1, which considers controllable generations, PV generations, wind generations, and energy storage systems.

PV system
Sun is the ultimate source of solar energy.The solar irradiance received from the sun can be converted into DC power with the help of solar cells (basic semiconductors), which is further converted into AC power with the help of inverters.The output power ( P pv ) of the PV module depends upon the effective global irradiance, the area of the module, the energy conversion efficiency of the solar module, and the temperature.It is given as, where G eff is the effective global irradiance η g is the conversion efficiency of the generator, A g is the active surface area of the module, T c is the temperature.Generally, the hourly irradiance is modeled by using the Beta distribu- tion function 36 and is given as, The value of the parameters a and b is calculated with the help of mean value u and standard deviation n as, (1) www.nature.com/scientificreports/

Wind system
The kinetic energy of wind can be converted into electricity with the help of the wind turbine, however the speed of the wind is intermittent.Therefore, the wind velocity (u) is modeled by using the Weibull probability distribution function and is given as 36 , The output power P W (u) of the wind turbine can be modeled in terms of the wind velocity (u) as, where P rated W (MW) is the rated power output of the wind turbine, u (m/s) is the maximum wind speed up to which generation is possible, u in (m/s) is the cut in speed at which wind turbine generates, u r (m/s) is the aver- age wind speed.

Controllable distributed generator (CDG)
It is one of the important components of the microgrid to supply the base demand and increase the system's reliability.
The cost associated with conventional generators is the fuel cost and is modeled as, where P i is the output power, a, b, and c are the fuel consumption curve parameters for any CDG whose units are $/Kw 2 h , $/Kwh and $ respectively.Another significant cost associated with CDGs is the emission cost.It is the penalty for polluting the environment and can be calculated using 37 .
Where K i is the penalty term for pollution, whose unit is $/Kg .m i , n i and o i are the emission coefficients, whose units are Kg/Kw 2 h , Kg/Kwh and Kg respectively.

Battery energy storage system
It is a device used to store energy.It takes energy from various sources, uses it when required by the loads, and helps balance generation and loads.The battery's power output can be positive or negative depending on the discharging or charging mode.This is determined by calculating the net energy and state of charge of the battery 38 .When the load is greater than a generation, the battery will get discharged, similarly, when we have sufficient generation, and the battery is not fully charged, it will be charging,

Scenario generation and reduction of uncertain parameters
There is uncertainty associated with renewable generation because of the intermittent nature of wind and solar irradiance.It can be forecasted based on the previous data, but there are some errors.These errors can be modeled using MCS 39 .

Scenario generation
To generate the scenarios, there is a need for the forecasted value and error associated with the various stochastic quantities like wind speed (to calculate the wind power) and global irradiance (to calculate PV output) over the entire scheduling horizon 36 .
Then, for each hour, the value of the stochastic quantity is equal to the sum of the forecasted value for that hour, and the error is generated randomly with the help of historical data 40,41 .The same procedure is followed for the load scenario generation as it also keeps changing from time to time and is uncertain.

Scenario reduction
Since there are many scenarios for this proposed optimization problem, a proper reduction method must be used to decrease the number of generated techniques so that the solution will become tractable.Clustering is a classic machine learning and computational geometry issue.In this work, we have used the K-mean clustering algorithm.The k-means method is one of the popular clustering methods (unsupervised) where the aim is to reduce the distance between the points of the same cluster 42 . (5)

Problem formulation
The main objective of microgrid operators is to minimize the overall operating cost of the microgrid by the maximum utilization of renewable energy.The operating cost function of the microgrid is as follows, where In Eq. ( 11), π s is the probability of each scenario, and s∈S π s = 1 , where S is the total number of scenarios.The α, β, γ , δ , and ζ are the priority factors that are changed for different cases to get the optimal solution.J 1 , J 2 , J 3 , J 4 , and J 5 are the costs associated with CDGs, emission costs, the cost associated with power exchange between microgrid and utility, battery costs, and the value of load loss, respectively.l+m j=1 j × g j represents the penalty term, where j is the penalty factor of the j th constraint and g j represents the j th constraint function that is being violated.l and m are the equality and inequality constraints, respectively.C CDG i is the operating cost, and P CDG i,t,s is the power output at time t for scenario s of the i th conventional generator, whose units are $/KWh are the charging and discharging costs associated with the battery.
The objective function given in (11) is subjected to multiple constraints, among which the power balance is the most important and is given by (17).
where P grid = P Buy − P Sell .
Other inequality constraints subjected to the (11) are as follows, P CDG is output of CDG and P CDG,Min and P CDG,Max are the minimum and maximum limits of the power out- put of CDG.P PV is the output of the PV panel, and it has a minimum limit of P PV ,Min and a maximum limit of P PV ,Max .P W is the wind output with P W,Min and P W,Max as the minimum and maximum limit, respectively.State of charge (SOC) is the indicator of battery energy, and it should also be in between minimum SOC Min and maximum limit SOC Max .

Optimization technique: Grey Wolf optimization GWO
GWO is a population-based metaheuristic algorithm proposed by Mirjaliali et al. in 2014.The social hierarchy and hunting mechanism of grey wolves inspire this algorithm.They belong to the Canidae family, and their scientific name is Canis lupus.Grey wolves are social animals and live together in a group called packs.Each pack consists of 6-12 wolves divided into four categories α G , β G , δ G , and ω G .The first level leads the pack to decisions such as hunting, sleeping location, etc.They need not be the strongest, but they are best at pack management.The second member of the hierarchy is β G .These are the supporting wolves that aid the leader in decision-making.Play the role of discipliner and advisor for the pack.It provides feedback to the alpha and guarantees that all other wolves obey the command.In the absence of α G , they will be leading the team.Sentinels, scouts, hunters, and caretakers form the next hierarchy.Scouts monitor the territory's boundary and warn the pack in case of danger.Sentinels guarantee safety for the other members of the pack.Hunters and caretakers hunt prey and take care of the pack's ill and wounded members.Rest all are the δ G , wolves.
The hunting mechanism of wolves is as follows: • Encircling prey: During the hunt, grey wolves encircle prey, whose position is ( X p ) • Hunting: A k and C k are coefficient vectors, here encircling and hunting is done through D k & X new , respec- tively along with new population are computed where, rd is a random number between 0 and 1, and a gwo changes linearly from 2 to 0 with each iteration.The entire process is described below • Attacking the prey: Once the prey stops moving, wolves attack the prey.
• Exploration: Grey wolves mainly seek according to the alpha, beta, and delta positions.They disperse from each other to hunt for prey and converge to attack prey.We use random values larger than 1 or less than -1 to mathematically describe divergence to force the search agent to diverge from the prey.
Another feature of GWO that encourages exploration is C .This vector has random values in the range [0, 2], allowing GWO to behave more randomly during optimization, promoting exploration and avoiding local optima.
Algorithm 1. GWO.Implementation steps of algorithm: Implementation of GWO algorithm for the objective function formulated in (11), is illustrated as follows: • Choose initial parameters and set priority factor γ = 0 for isolated mode.
• Choose other priority factors (α G , β G , γ G and δ G ) for Grid-connected mode.
• Stop the procedure once termination criterion meets.
The flowchart for the proposed algorithm is shown in Fig. 2.

Results and discussion
To validate the proposed methodology, a standard LV Microgrid CIGRE test network is considered.The various data of LV MG CIGRE test system for wind turbine, photovoltaic, battery energy storage system, controllable load etc. are collected from 43 .The GWO algorithm, as discussed in Sect.Optimization technique: Grey Wolf optimization GWO, is implemented in MATLAB software to get the optimal solution of the developed optimization problem, along with the Jaya and PSO algorithms.Each search agent in the optimisation approach has number of variables that keep changing every hour.Cost analysis is carried out to demonstrate the efficiency of GWO and Jaya.At first, the total 2000 scenarios for loads, PV output, and wind output were generated to get all www.nature.com/scientificreports/ the uncertainties associated with them, as discussed in the Sect.Scenario generation and reduction of uncertain parameters.
Figure 8 shows all the strategies generated for load using the MCS for the entire day.The blue line curve shows the upper limit curve of the load profile, the green line shows the lower limit of the load curve, and the red dotted curve is the forecasted load curve.Figure 3 is all the scenario sets for the wind power output with a deviation of 15%.The blue curve is the upper limit of the wind curve for 24 hours; the green colour shows the lower acceptable limit curve for wind scenarios; and the red curve shows the predicted values of the wind but is highly uncertain compared to the load and PV scenarios.Figure 4 shows the multiple techniques for solar output generated with the help of MCS using the base value forecasted (red curve) and the error produced using their probability distribution function.The blue and green lines in the set of scenarios show the upper and lower limits of the solar output with the maximum deviations.
It is reduced into smaller samples using the K-mean clustering algorithms to reduce the computational time and complexity.Figure 5 is the graph obtained after applying the k-mean algorithm to the load scenario graph.The set of two thousand load curves is reduced to the group of ten load curves represented by S1, S2, S3, S4, S5, S6, S7, S8, S9, and S10, respectively.In Figs. 6 and 7, the total 2000 of wind power output and solar power output curves are also reduced to a set of 10 curves represented as S1 to S10 with the help of K-mean clustering, respectively.Data sets of PV, wind, and load are obtained with their associated probabilities for each of the ten scenarios.

Grid connected mode
The grid can be considered the virtual generator.A microgrid can buy power when there is a deficit and supply power when it has excess renewable generation.
In Table 1, different priority factor terms like α , β , γ , δ , and ζ show the relative significance of each cost component in the overall objective function.Based on these priority factors, five cases have been considered.is the weight factor for the emission cost J 2 , and the values of γ and δ are 0.1 and 0.1, respectively, and these show the weight factor of the cost associated with energy exchanged with grid (J 3 ) and battery cost (J 4 ) , respectively.• Case2: The value of α is taken as .6,which is associated with fuel cost J 1 ; the value of β is 0.1; it is the weight factor for the emission cost J 2 ; and the values of γ and δ are 0.2 and 0.1, respectively, and these show the weight factors of J 3 and J 4 , respectively.• Case3: The value of α is reduced to .5, the value of β is .1,and the values of γ and δ are 0.25 and 0.15, respec- tively.• Case4: The value of α is .5, the value of β is .15,and the values of γ and δ are 0.2 and 0.15, respectively.• Case5: For this case, the values of α , β , γ , and δ are assumed to be 1.
In each case, 10 scenarios are taken, with (PV1W1L1) or S1 of PV from Fig. 8, S1 of wind from Fig. 7, S1 of load from Fig. 6 being the first scenario or the first data set, PV2W2L2 (S2 of PV, S2 of wind, S2 of load) being the second scenario (second data set), and so on.For these data sets, optimisation is carried out using the GWO and Jaya algorithms.For each scenario, there is an optimal value, but we are focusing on stochastic optimisation, so to consider the uncertain nature, we need to take the average optimal values of all the scenarios.
From Table 3, GWO gives better results than Jaya for all the cases.The lowest cost for case 4 in the GWO algorithm value is 4004$ .The standard deviation is less when using GWO and quite high when using Jaya.
The main cost is the operating cost of CDGs, followed by the grid exchange cost, battery cost, and emission cost.The same can be observed from Table 2, when the priority of all the cost terms is equal, the cost is maximum,  as in case 5 of all the optimisation methods, but if it is allotted properly, the overall cost reduces.From Table 3, GWO is giving better results than the Jaya algorithm for my problem.Although the difference between the optimal cost obtained from GWO and Jaya is not high for one day, it will significantly affect the cost for longer.Figure 9 shows the load curve, total of CDGs power, wind power output, solar output, exchange with the grid, battery power output, and dump energy (PL-PG) by using the GWO algorithm.Similarly, Fig. 10 shows the load curve, the total of CDGs power, wind power output, solar output, exchange with the grid, battery power output, and the dump using the Jaya algorithm.

Isolated mode
In this mode, is no grid to act like a virtual generator, so we will go for load curtailment when we don't have sufficient generation.This load curtailment is associated with some revenue loss for the operator, which we call VOLL (value of loss load), which is higher than the price of electricity offered to the customer.In isolated mode, the third term of the objective function (exchange with the grid) is not there, and the Lshed term comes into the picture.
• Case1: The value of α is taken as .75, it shows the relative significance of fuel cost J 1 , the value of β is .04, it is the weight factor for the emission cost J 2 , and the values of ζ and δ are 0.1 and 0.1, respectively, and these show the weight factor of the cost associated with load shedding J 5 and battery cost (J 4 ) , respectively.• Case2: The value of α is taken as .6,which is associated with fuel cost J 1 ; the value of β is .1; it is the weight factor for the emission cost J 2 ; and the values of ζ and δ are 0.2 and 0.1, respectively, and these show the weight factors of J 5 and J 4 , respectively.• Case3: The value of α is reduced to .5, the value of β is .1,and the values of ζ and δ are 0.25 and 0.15, respec- tively.• Case4: The value of α is .5, the value of β is .15,and the values of ζ and δ are 0.2 and 0.15, respectively.• Case5: For this case, the values of α , β , ζ , and δ are assumed to be 1.Table 5 observed that the overall cost has increased in isolated mode on the operator side sometimes when GWO optimization is used and for all instances where the Jaya algorithm is used.This is because of load curtailment to balance demand and supply and improve reliability.Load curtailment is associated with incentives given to the customer because of overall cost increases.For the GWO algorithm, the best optimal cost is 3754$ for case 4, and the worst case is 9106$, whereas for Jaya, the best case is case 3 with 4222$ dollars, and the worst case is case 5 with 11608$.The detailed description of different cost components obtained in isolated mode is in Table 4 for PSO, GWO, and Jaya.

Conclusion
This paper proposes a day-ahead stochastic scheduling problem for the MG with uncertainty.The main aim is to minimise the overall cost of the microgrid, and a scenario-based method is modelled for the uncertain nature of RESs (PV and wind) and load.The economic load dispatch problem has been solved using two popular metaheuristic algorithms, the Grey-Wolf algorithm and Jaya.Jaya and PSO performed equally well compared to GWO.The proposed strategy's effectiveness in economics and reliability is investigated on a standard benchmark LV microgrid CIGRE test network.Economic load dispatch was performed for both the grid-connected and the islanded microgrid.During isolated mode, the cost was maximised by the Jaya algorithm and a little less by GWO.In grid-connected mode, GWO has obtained the best optimal solution.

Figure 2 .
Figure 2. Flowchart of the proposed

Figure 5 .
Figure 5. Reduced scenarios of load for 24 hours.

Figure 6 .
Figure 6.Reduced scenarios of wind output for 24 hours.

Figure 7 .
Figure 7. Reduced scenarios of solar output for 24 hours.

Figure 9 .
Figure 9. power profiles of the CDGs, renewables, and Grid Supply System considering battery using GWO.

Figure 10 .
Figure10.power profiles of the CDGs, renewables, and grid supply system considering battery using Jaya.
and Kw, respectively.C SU i,t,s and C SD i,t,s are the start-up and shut-down costs.m i , n i , and o i are the emission cost coefficients of the CDGs.ρ P PV + P W + P grid + P CDG + P Lshed = P Load ,

Table 1 .
Different cases considered for optimization.